// 获取local
export function getLocalLoginInfor() {
    const yqtokenExpiration = localStorage.getItem("yqtokenExpiration");//
    if (!!yqtokenExpiration && new Date(Number(yqtokenExpiration)) > new Date()) {
        const yqtoken = localStorage.getItem("yqtoken");
        const yquser = localStorage.getItem("yquser");
        // console.log("yquser",yquser)
        return yqtoken && yquser ? [yqtoken, JSON.parse(yquser)] : ["", {}];
    } else {
        return ["", {}];
    }
}

export function getLocalUser() {
    const yquser = localStorage.getItem("yquser");
    return yquser ? JSON.parse(yquser) : {}
}

export function getLocalToken() {
    const yqtoken = localStorage.getItem("yqtoken")
    return yqtoken ? yqtoken : "";

}

//设置local
export function setLocalLoginInfor(token, user, tokenExpiration) {
    localStorage.setItem("yqtoken", token);
    localStorage.setItem("yquser", JSON.stringify(user));
    localStorage.setItem("yqtokenExpiration", tokenExpiration)
}

export function setLocalUser(user) {
    localStorage.setItem("yquser", JSON.stringify(user));
}

export function setLocalToken(token) {
    localStorage.setItem("yqtoken", token);
}

// 移除logininfo
export function removeLocalLoginInfor() {
    localStorage.removeItem("yqtoken");
    localStorage.removeItem("yquser");
    localStorage.removeItem("yqtokenExpiration")
}

export function removeLocalToken() {
    localStorage.removeItem("yqtoken");
}

export function removeLocalUser() {
    localStorage.removeItem("yquser");
}

export function removeLocalExpiration() {
    localStorage.removeItem("yqtokenExpiration")
}
